package io.renren.modules.jxgk.controller;

import io.renren.common.annotation.SysLog;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;
import io.renren.common.utils.R;
import io.renren.modules.jxgk.entity.ClassDiaryTeacherSum;
import io.renren.modules.jxgk.entity.TeacherEvaluationSumEntity;
import io.renren.modules.jxgk.service.TeacherEvaluationSumService;
import io.renren.modules.jxgkphone.service.TeachingEvaluationService;
import io.renren.modules.jxgkphone.tempEntity.TempStudentAttendence;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.repository.query.Param;
import org.springframework.web.bind.annotation.*;
import com.wuwenze.poi.ExcelKit;

import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


@RestController
@RequestMapping("TeacherEvaluationSum/")
public class TeacherEvaluationSumController {

    @Autowired
    TeacherEvaluationSumService teacherEvaluationSumService;


    @RequestMapping("Select")
    public R list(@RequestParam Map<String, Object> params){
        //查询列表数据
        Query query = new Query(params);
        List<TeacherEvaluationSumEntity> cse = teacherEvaluationSumService.queryList(query);
        int total = teacherEvaluationSumService.queryTotal(query);

        PageUtils pageUtil = new PageUtils(cse, total, query.getLimit(), query.getPage());

        return R.ok().put("page", pageUtil);
    }
    @RequestMapping("/export")
    public R export(HttpServletResponse response, String teacherName) {
        List<TeacherEvaluationSumEntity> cse =null;
        Map<String,Object> map=new HashMap<String,Object>();
        if(teacherName!=null&&!teacherName.equals("")){
            map.put("teacherName",teacherName);
        }
        try{
            cse=teacherEvaluationSumService.queryList( map);
            ExcelKit.$Export(TeacherEvaluationSumEntity.class, response).toExcel(cse, "评价教师数据汇总");
        }catch (Exception e)
        {
            e.printStackTrace();
        }
        return R.ok();
    }

    @RequestMapping("getTeacherEvaluationEntity")
    public R getTeacherEvaluationEntity(@Param("courseId") String courseId,@Param("courseId") String teacherId, @Param("courseId")String studentSchoolId,@Param("courseId") String evaluationTime,Map<String,Object> map){
        //查询列表数据
        if(map==null) {
            map = new HashMap<String, Object>();
        }
        List<ClassDiaryTeacherSum> cse = null;
        if(courseId!=null&&!courseId.equals("")){
            map.put("courseId",courseId);
        }
        if(teacherId!=null&&!teacherId.equals("")){
            map.put("teacherId",teacherId);
        }
        if(studentSchoolId!=null&&!studentSchoolId.equals("")){
            map.put("studentSchoolId",studentSchoolId);
        }
        if(evaluationTime!=null&&!evaluationTime.equals("")){
            map.put("evaluationTime",evaluationTime);
        }
        Object object=teacherEvaluationSumService.findAllEvaluationContentMap(map);

        return R.ok().put("page", object);
    }
}